{% load i18n %}

<script type="text/javascript" charset="utf-8">
	var ajax_get_comment_form_url = '{{ ajax_get_comment_form_url }}'
	
	//-------------------------------------------------------------------------
	// 
	function displayFormComment() {
		c=document.getElementById('add-comment')
		if (c.style.display == "none") {
			c.style.display="block"
			loadAjaxCommentForm();
		} else {
			c.style.display = "none"
		}
	}	
	
	//-------------------------------------------------------------------------
	// 
	function ajaxCommentFormResult(responseText) {	
		document.getElementById('add-comment').innerHTML = responseText;
		//document.getElementById('add_new_comment').innerHTML = "Новый комментарий"
		//document.getElementById('add_new_comment').style.borderBottom = "1px solid #dddddd";
    }
	
	//-------------------------------------------------------------------------
	// 
	function loadAjaxCommentForm() {
		//doAjax("GET", ajax_get_comment_form_url, null, ajaxCommentFormResult);
		$.get(ajax_get_comment_form_url, null, ajaxCommentFormResult);
	}
		
</script>

<div class="entries_header">
{% trans "comments" %} ({{ comments_count }}) 
</div>

<div id="comments" class="entries">
     <a href="#" onclick="displayFormComment(); return false;">
		Добавить комментарий &raquo;
	</a>
	
	<div id="add-comment">
	</div>

	<a name="comments"></a>
	<ul>
	{% for c in comments %}
	    <li class="{% cycle row1,row2 %}">
		    <div class="ucomment">
		    	{% if user.is_staff %}
		    	<a href="/comments/{{c.object_id}}/{{c.id}}/delete/">
                <img src="/appmedia/delete.gif" style="vertical-align:middle" alt="[x]">
                </a>
		    	{% endif %} 
		    	
		    	<img src="/appmedia/comment.gif" style="vertical-align:middle">
		    	<a href="/user/{{ c.user_name }}/">
		    	{{ c.user_name }}
		    	</a>
		    	<span class="domment">
		    		{{ c.pub_date|date:"F jS Y" }} {% trans "at" %}  {{ c.pub_date|date:"H:i" }}
		    	</span>	
		    </div>
		    
		    <div class="comment_post">
		    	{{ c.comment|escape|linebreaks }}
		    </div>
	    </li>
	{% endfor %}
	</ul>

<script type="text/javascript" charset="utf-8">
	document.getElementById('add-comment').style.display="none"
</script>
